<template>
  <rx-dialog @handOk="okFun" @cancel="cancelFun">
    <rx-layout>
      <div slot="center">
        <rx-fit>
          <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
            <div class="table-page-search-wrapper">
              <a-form layout="inline">
                <a-row :gutter="24">
                  <a-col :span="8">
                    <a-form-item :label="i18n('form.name','栏目名')">
                      <a-input :placeholder="i18n('form.name','栏目名','input')" v-model="queryParam['Q_a.NAME__S_LK']"/>
                    </a-form-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-item :label="i18n('form.key', '栏目别名')">
                      <a-input :placeholder="i18n('form.key', '栏目别名','input')" v-model="queryParam['Q_a.KEY__S_LK']"/>
                    </a-form-item>
                  </a-col>
                  <a-col :md="8" :sm="24">
                      <span class="table-page-search-submitButtons">
                        <a-button @click="$refs.table.loadData()" icon="search" type="primary">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                        <a-button @click="resetSearch" style="margin-left: 4px">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                      </span>
                  </a-col>
                </a-row>
              </a-form>
            </div>
          </div>
          <rx-grid
              ref="table"
              :bordered="isBorder"
              :allowRowSelect="true"
              :multiSelect="false"
              :columns="columns"
              :defaultPageSize="10"
              url="/api-portal/portal/core/insColumnDef/query"
              :queryParam="queryParam"
              data-field="result.data"
              :pageSizeOptions="['10','30','40']"
              id-field="colId"
              @selectChange="onSelectChange"
          >
            <span slot="isMobileName" slot-scope="{text, record, index}">
              {{ getWhetherCustom(whetherCustom) }}
            </span>
            <span slot="name" slot-scope="{text, record, index}">
                {{$i18(text,"栏目名国际化")}}
            </span>
          </rx-grid>
        </rx-fit>
      </div>
    </rx-layout>

  </rx-dialog>
</template>

<script>
import InsColumnDefApi from '@/api/portal/core/insColumnDef';
import InsColumnTempApi from '@/api/portal/core//insColumnTemp';
import InsColumnDefEdit from './InsColumnDefEdit';
import {BaseList, Util, RxGrid} from "@lowcode/jpaas-common-lib";

export default {
  name: 'InsColumnDefList',
  mixins: [BaseList],
  components: {
    InsColumnTempApi,
  },
  props: {
    single: {
      type: Boolean,
      default: true
    },
    layerid: {
      type: String,
      default: ""
    },
    destroy: {
      type: Function
    }
  },
  data() {
    return {
      columns: [
        {title: '#', dataIndex: 'serial', type: 'indexColumn', scopedSlots: {customRender: 'serial'}, width: 60},
        {title: this.i18n('form.name','栏目名'), dataIndex: 'name', width: 120,scopedSlots: {customRender: 'name'}},
        {title: this.i18n('form.key','栏目别名'), dataIndex: 'key', width: 120},
        {title: this.i18n('form.type','类型'), dataIndex: 'typeName', width: 100}
      ],
      component: InsColumnDefEdit,
      comment: this.i18n('list.comment','栏目定义'),
      widthHeight: ['800px', '600px'],
      tempTypeList: []
    }
  },
  created(){
    this.queryParam.isSelect=true;
  },
  methods: {
    i18n(name,text,key){
        return this.$ti18(name,text,"insColumnDef",key);
    },
    getWhetherCustom(val) {
        return val && val == 0 ? this.i18n('list.no','否') : this.i18n('list.yes','是');
    },
    getSelect() {
      var selectObj = {
        single: this.single,
        data: this.selectedRows
      }
      return selectObj;
    },
    okFun() {
      Util.closeWindow(this, "ok");
    },
    cancelFun() {
      Util.closeWindow(this, "cancel");
    },

  }
}
</script>
<style scoped>
.table-operator {
  padding: 4px;
  margin-bottom: 56px;
}

</style>

